<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>艺术家基本资料修改</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>

<script type="text/javascript">

$(function(){
	$("#painterLink").click(function(){
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=painter&sharpId=6',{title:'修改艺术家照片',width:800,height:550},false);
    });
	
	checkMarketIndex();
	
	var city_id = '${painter.cityInfo.id}';
	checkCity(city_id);

    $("#englishName").blur(function(){
    	checkEnglishName();
     });
});

function checkMarketIndex(){
	
	var time_period1  = '${painter.newIndex.time_period }';
	var time_period2  = '${painter.maxIndex.time_period }';
	var time_period3  = '${painter.minIndex.time_period }';
	var time_period4  = '${painter.newestIndex.time_period }';

	$("#time_period_1").val(time_period1);
	$("#time_period_2").val(time_period2);
	$("#time_period_3").val(time_period3);
	$("#time_period_4").val(time_period4);
}

	function checkForm(){

		var name = $.trim($("#name").val());
		if( name  ==  ""){
			$("#name").focus();
			 alert("艺术家姓名不能为空。");
			 return false;
		}

		if(!checkEnglishName()){
			return false;
		}

		var picImage = $("#picImage").val();
		if( picImage == "" ){
			alert("请上传艺术家照片");
			return false;
		}

		var age = $("#age").val();
		if(age == ""){
			$("#age").val("");
			$("#age").focus();
			alert("请输入合法的年龄");
			return false;
		}

		var achievement1 = $("#achievement1").val();
		if(achievement1 == ""){
			alert("请填写艺术家从艺历程。");
			return false;
		}

		var province = $("#provinceInfoSelect").val();
		var city = $("#cityInfoSelect").val();
		var address =  $.trim($("#address").val());
		if(province == "" && address == ""){
			alert("请填写名家的所在地");
			return false;
		}
		
		if(window.confirm("确认修改艺术家资料？")){
			$.ajax({
				type:'POST',
				url:'${ctx }/painter/modify.do',
				async : false, //ajax同步
				data:$("#painterForm").serialize(),//序列化表单里所有的内容
				success: function(data){
					 var arr = data.split(",");
					if(arr.length > 2 ){
						if(arr[0]=='0000'){
			    			alert("艺术家资料保存成功！");
			    			var win = art.dialog.open.origin;//来源页面
							win.location.reload();
							return false;
						}
					}else{
						alert("艺术家资料保存失败！");
						return false;
					}
				}
			});
		}
	}

	/**
	* 检查汉语拼音是否重复
	*/
	function checkEnglishName(){
        var englishName = $("#englishName").val();
        if(englishName == ""){
			alert("请填写艺术家姓名的汉语拼音。");
			return false;
        }
        var painter_id = $("#painter_id").val();
        return $.ajax({
			type:'POST',
			url:'${ctx }/front/painterAction!checkEnglishName.do?englishName='+englishName+'&painter_id='+painter_id,
			async : false, //ajax同步
			success: function(data){
				var returnMsg = eval('('+data+')');
				if(returnMsg.code == '0000'){
					return true;
				}else{
					alert(returnMsg.message);
					return false;
				}
			}
		});
	}
</script>
</head>
<body>

<form action="${ctx }/painter/modify.do" method="post" id="painterForm" name="painterForm">
<table width="800" border="0" cellspacing="0" cellpadding="0" style="background: #ffffff;border: 1px solid #ccc;">
            <tr>
              <td colspan="100%" class="bt14A" align="center">修改艺术家${painter.name }基本资料
             </td>
            </tr>
           <tr>
              <td class="bt14A" align="right"><span class="style15">*</span>艺术家姓名：</td>
              <td class="bt14A">
                	<input name="painter.name" type="text" size="20" id="name" value="${painter.name }"  maxlength="40">
                	汉语拼音：<input name="painter.englishName" type="text" size="10" id="englishName"  value="${painter.englishName }" maxlength="40">
              </td>
              <td valign="top" width="160" rowspan="10" align="left">
                  <table width="150" height="184" border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
                    <tr>
                      <td bgcolor="#FFFFFF">
                      	 <div id="photoTd" style="width: 147px;height: 181px;vertical-align: middle;text-align: center;overflow: hidden;">
                      		 <img src="${painter.originalImagePath }" border="0" width="147" height="181">
                      	 </div></td>
                    </tr>
                  </table>
              </td>
           </tr>
           <tr>
              <td class="bt14A"></td>
              <td class="bt14A">
              		字<input name="painter.zi" type="text" size="6" value="${painter.zi }" maxlength="15">
            		号<input name="painter.hao" type="text" size="6" value="${painter.hao }" maxlength="15">
              </td>
              <td></td>
            </tr>
            <tr>
             <c:if test="${painter.type == 1 }">
               <td class="bt14A" align="right"><span class="style15">*</span> 选择门类：</td>
               <td class="bt14A">
                  <select name="painter.catalogType.id" id="catalogTypeSelect">
	         			 <c:forEach items="${catalogTypeList}" var="catalogType" varStatus="status">
	            	 		<option value="${ catalogType.id}" <c:if test="${ painter.catalogType.id == catalogType.id }">selected="selected"</c:if>/> ${ catalogType.name}</option>
	         			 </c:forEach>
		     	  </select>	
               </td>
                <td></td>
              </c:if>
             <c:if test="${painter.type == 2 }">
                 <td class="bt14A" align="right"><span class="style15">*</span> 选择年代：</td>
              	<td class="bt14A" align="left">
                 	<select name="painter.decade">
                    <option value="1" <c:if test="${painter.decade ==1}">selected="selected"</c:if>>近现代国画名家</option>
                    <option value="2" <c:if test="${painter.decade ==1}">selected="selected"</c:if>>近现代油画名家</option>
                    <option value="3" <c:if test="${painter.decade ==3}">selected="selected"</c:if>>当代国画名家</option>
                    <option value="4" <c:if test="${painter.decade ==4}">selected="selected"</c:if>>当代油画名家</option>
                    <option value="5" <c:if test="${painter.decade ==5}">selected="selected"</c:if>>古代国画名家</option>
                    <option value="6" <c:if test="${painter.decade ==6}">selected="selected"</c:if>>国外名家</option>
                   </select>
                 </td>
                  <td></td>
              </c:if>
            </tr>
            <tr>
              <td class="bt14A" align="right"><span class="style15">*</span>艺术家照片：</td>
              <td class="bt14A"><span class="style18"><a id="painterLink" style="cursor: pointer;color: red">上传</a></span></td>
               <td></td>
              </tr>
            <tr>
              <td class="bt14A" align="right"><span class="style15">*</span> 年 龄：</td>
              <td class="bt14A">
                <input name="painter.age" type="text" size="3" id="age" maxlength="4" value="${painter.age }">年生
                <c:if test="${painter.type == 2 }">
                	<input name="painter.endAge" type="text" size="3" id="endAge" maxlength="4" value="${painter.endAge }">年逝
                </c:if>
            </td>
             <td></td>
            </tr>
         <tr>
           <td class="bt14A" align="right">毕业院校：</td>
           <td class="bt14A">
            	<input name="painter.graduatedFrom" type="text" size="30" id="graduatedFrom"  value="${painter.graduatedFrom }" maxlength="50"></td>
           <td></td>
           </tr>
         <tr>
           <td class="bt14A" align="right">职业/头衔：</td>
           <td class="bt14A">
            	<input name="painter.honour" type="text" size="40" id="honour"  value="${painter.honour }" maxlength="100">
           </td>
           <td></td>
         </tr>
         <c:if test="${painter.type == 2 }">
	               <%@ include file="/commons/painter_star_market_fragment.jsp" %>
	     </c:if>
         <tr>
           <td class="bt14A" align="right"><span class="style15">* </span>
           <c:if test="${painter.type == 1 }">
           		所在地：
           </c:if>
            <c:if test="${painter.type == 2 }">
                  	籍贯:
            </c:if>
           </td>
           <td class="bt14A">
               <select name="painter.provinceInfo.id" id="provinceInfoSelect" onchange="changeProvince()">
                   <option value="">选择省份</option>
                   <c:forEach items="${provinceInfoList}" var="provinceInfo" varStatus="status">
           				<option value="${ provinceInfo.id}" <c:if test="${painter.provinceInfo.id == provinceInfo.id }">selected="selected"</c:if>/> ${ provinceInfo.name}</option>
       			   </c:forEach>
               </select>
                 <select name="painter.cityInfo.id" id="cityInfoSelect">
                   <option value="">选择县市</option>
                 </select>
                 <c:if test="${painter.type == 2 }">
                	<input name="painter.address" type="text" size="40" id="address" value="${painter.address }">
                </c:if>
           </td>
            <td></td>
           </tr>
         <tr>
           <td class="bt14A" align="right"><span class="style15">*</span> 艺术人生：</td>
           <td style="padding-left: 5px;" colspan="2"><textarea rows="8" cols="70"  id="achievement1" name="painter.description">${painter.description }</textarea></td>
         </tr>
        <tr>
            <td width="160">
           <!-- 隐藏域 begin  -->
              		<input name="painter.id" type="hidden" size="20" id="painter_id" value="${painter.id }">
              		<input name="painter.imageInfo.id" type="hidden"  id="picImage" value="${painter.imageInfo.id }">
              		<input name="painter.type" type="hidden"  id="painter_type" value="${painter.type }">
          		<!-- 隐藏域 end  -->  
          	</td>
            <td colspan="2" style="padding: 15px 0px 20px 5px;">
           		<img src="../images/an24.gif" width="114" height="31" onClick="javascript:checkForm()" style="cursor: pointer ;border: 0"> 
          	</td>
       </tr>
 </table>
</form>

</body>
</html>